package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.ProductModelMapper;
import com.eos.orm.mybatis.model.ProductModel;
import com.eos.orm.mybatis.model.ProductModelExample;
/**
 * product_model产品型号表的CURD操作
 * @author sz
 *
 */
public class ProductModelMapperImpl extends AbstractSqlSessionFactory implements
		ProductModelMapper {

	public int countByExample(ProductModelExample example) {
		return 0;
	}

	public int deleteByExample(ProductModelExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ProductModelMapper mapper = session.getMapper(ProductModelMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ProductModelMapperImpl.deleteByPrimaryKey throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insert(ProductModel record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ProductModelMapper mapper = session.getMapper(ProductModelMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ProductModelMapperImpl.insert throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insertSelective(ProductModel record) {
		return 0;
	}

	public List<ProductModel> selectByExample(ProductModelExample example) {
		List<ProductModel> templist = new ArrayList<ProductModel>();
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ProductModelMapper mapper = session.getMapper(ProductModelMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ProductModelMapperImpl.selectByExample throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return templist;
	}

	public ProductModel selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ProductModelMapper mapper = session.getMapper(ProductModelMapper.class);
			return mapper.selectByPrimaryKey(id);
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ProductModelMapperImpl.selectByPrimaryKey throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return null;
	}

	public int updateByExample(ProductModel record, ProductModelExample example) {
		return 0;
	}

	public int updateByExampleSelective(ProductModel record,
			ProductModelExample example) {
		return 0;
	}

	public int updateByPrimaryKey(ProductModel record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(ProductModel record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ProductModelMapper mapper = session.getMapper(ProductModelMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ProductModelMapperImpl.updateByPrimaryKeySelective throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

}
